You are here: Debugging VBScript

Debugging VBScript

No matter how good of a programmer you are, you will eventually want to debug your VBScript code, if not due to programming errors, then due to use cases or data that you did not anticipate. The Visual Studio programmer has the convenience of a debugger built into that development tool but beyond the script validation feature of the Meridian Enterprise Script Editor, you cannot debug VBScript in the editor. For real debugging, you need a different tool. The tool to use depends on the client application where you want to debug the script:

The key to debugging VBScript from applications other than PowerUser is the ability of Visual Studio to attach itself to those applications.

Before you begin

Visual Studio 2008 or higher must be installed on the computer running the application from which you want to debug. Other debugging tools can be used as long as they support attaching themselves to a running process.

To debug VBScript in any Windows application with Visual Studio:

  1. Start the application that hosts the VBScript that you want to debug. Perform the actions that lead up to the point where your VBScript is about to execute and you want to start debugging.
  2. Start Visual Studio. The Visual Studio Start Page appears.
  3. On the File menu, select New Project. The New Project dialog appears.
  4. In Project Types, expand Other Project Types, click Visual Studio Solutions, select Blank Solution, and then click OK. A new project is created.

Note    The name of the project is irrelevant because you will not add any code to the project and will discard it when you are finished using the debugger.

  1. On the Tools menu, select Attach to Process. The Attach to Process dialog appears.
  2. Enable Show processes from all sessions. The Available Processes list refreshes to show additional processes.
  3. In Available Processes, select the name of the executable for the host application that you that you started in step 1 and click Attach. For example, to debug a Web Access session, select w3wp.exe. If the Attach Security Warning dialog appears, click Attach. The Solution Explorer opens and lists one or more occurrences of AMScriptHost.
  4. On the Debug menu, select Break All (or press Ctrl+Alt+Break).
  5. Perform the action in the host application that will run the VBScript code that you want to debug. The Windows focus switches to Visual Studio and a new window opens, either VBScript - script block [dynamic] if a configuration expression is about to execute or BlueCielo VB Script [dynamic] if a sub-procedure or function in the event handler code module is about to execute. The next statement that will execute is highlighted and execution stops to allow you to debug.

When script first executes after the process is attached to Visual Studio, the vault's active VBScript configuration expressions and the event handler code module are loaded in Visual Studio. You might have to step over (press F10) some configuration expressions or sub-procedures before the particular expression, sub-procedure, or function that you want to debug is entered. Whenever the event handler code module is loaded, you can set breakpoints in the BlueCielo VB Script [dynamic] window and step through the code similar to debugging in PowerUser as described in Understanding the Microsoft Script Debugger.

To open the BlueCielo VB Script [dynamic] window, in the Solution Explorer expand Script Documents, expand AMScriptHost, and double-click BlueCielo VB Script.

Just like with using the Microsoft Script Debugger, to make changes to script code, you must edit it in Meridian Enterprise Configurator, save your changes, reopen the vault in the host application, and restart this task from step 5.

  1. When you are finished debugging, exit Visual Studio without saving the project.

Following is a list of host applications related to Meridian Enterprise that you can attach to debug VBScript code:

To further aid in debugging, you can enable logging of VBScript events, command scripts, evaluated expressions, and external function calls. You can enable logging only for PowerUser and the Meridian Web Client

To enable VBScript logging and viewing:

  1. If PowerUser is open, close it.
  2. In the Windows registry, set the following registry values that are also described in the BlueCielo Meridian Enterprise Administrator's Guide:

The log file is restarted for each client session. The file includes the time, description, and source of the events.

Notes

To view the log with PowerUser:

  1. On the View menu, point to Arrange Layout and then click Log. The Log window can be floated or docked as described in the BlueCielo Meridian Enterprise User's Guide.

To download the log with the Meridian Web Client:

  1. Right-click to show the shortcut menu.
  2. In the Miscellaneous group, click Download Log. The file downloads to your browser where you can save and view it.

Related concepts

Understanding the Meridian Enterprise Script Editor

Understanding the Microsoft Script Debugger

Understanding configuration expressions

Understanding the Meridian object model

Understanding the Meridian functions

Understanding Meridian event procedures

Understanding automation objects

Understanding object arguments

Understanding VBScript and Web Access

Understanding the CurrentPropertyName property

Related information

VBScript examples

Formatting text with RTF codes

Meridian Enterprise command identifiers

The Meridian API constants